package com.feng.chat.mapper;

import com.feng.chat.entity.TalkSession;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 用户聊天列表 Mapper 接口
 * </p>
 *
 * @author dyf
 * @since 2022-05-31
 */
public interface TalkSessionMapper extends BaseMapper<TalkSession> {

    @Select("SELECT id,talk_type,user_id,receiver_id,is_top,is_robot,is_delete,is_disturb,created_at,updated_at FROM talk_session WHERE user_id=#{id} AND is_delete = 0 ORDER BY updated_at DESC")
    public List<TalkSession> getSessionList(Integer id);

    @Select("SELECT id,talk_type,user_id,receiver_id,is_top,is_robot,is_delete,is_disturb,created_at,updated_at FROM talk_session WHERE receiver_id =#{receiverId} AND user_id =#{id}")
    public TalkSession getSession(Integer id,Integer receiverId);

}
